﻿using BLL;
using Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace echuCMS
{
    public partial class FormAddOrg : Form
    {
        string cityName;
        internal Action refresh;

        public FormAddOrg(string cityName)
        {
            this.cityName = cityName;
            InitializeComponent();
        }
        public FormAddOrg()
        {
            InitializeComponent();
        }

        private void FormAddOrg_Load(object sender, EventArgs e)
        {
            textBoxCityName.Text = cityName;
        }

        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxOrg.Text.Trim()))
            {
                MessageBox.Show("请输入事业部名称");
            }
            else
            {
                OrganizationCity org = new OrganizationCity();
                org.CityName = cityName;
                org.SalesOrganization = textBoxOrg.Text.Trim();
              int i = OrgService.addOrg(org);
                if (i > 0)
                {
                    MessageBox.Show("添加成功");
                    this.textBoxOrg.Text = "";
                }
            }
        }

        private void FormAddOrg_FormClosed(object sender, FormClosedEventArgs e)
        {
            refresh();
        }
    }
}
